home *** CD-ROM | disk | FTP | other *** search
- '\"
- '\" Copyright (c) 1993 The Regents of the University of California.
- '\" All rights reserved.
- '\"
- '\" Permission is hereby granted, without written agreement and without
- '\" license or royalty fees, to use, copy, modify, and distribute this
- '\" documentation for any purpose, provided that the above copyright
- '\" notice and the following two paragraphs appear in all copies.
- '\"
- '\" IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY
- '\" FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
- '\" ARISING OUT OF THE USE OF THIS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
- '\" CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- '\"
- '\" THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
- '\" INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
- '\" AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
- '\" ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
- '\" PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
- '\"
- '\" $Header: /user6/ouster/tcl/man/RCS/open.n,v 1.1 93/05/10 17:10:32 ouster Exp $ SPRITE (Berkeley)
- '\"
- .\" The definitions below are for supplemental macros used in Tcl/Tk
- .\" manual entries.
- .\"
- .\" .HS name section [date [version]]
- .\" Replacement for .TH in other man pages. See below for valid
- .\" section names.
- .\"
- .\" .AP type name in/out [indent]
- .\" Start paragraph describing an argument to a library procedure.
- .\" type is type of argument (int, etc.), in/out is either "in", "out",
- .\" or "in/out" to describe whether procedure reads or modifies arg,
- .\" and indent is equivalent to second arg of .IP (shouldn't ever be
- .\" needed; use .AS below instead)
- .\"
- .\" .AS [type [name]]
- .\" Give maximum sizes of arguments for setting tab stops. Type and
- .\" name are examples of largest possible arguments that will be passed
- .\" to .AP later. If args are omitted, default tab stops are used.
- .\"
- .\" .BS
- .\" Start box enclosure. From here until next .BE, everything will be
- .\" enclosed in one large box.
- .\"
- .\" .BE
- .\" End of box enclosure.
- .\"
- .\" .VS
- .\" Begin vertical sidebar, for use in marking newly-changed parts
- .\" of man pages.
- .\"
- .\" .VE
- .\" End of vertical sidebar.
- .\"
- .\" .DS
- .\" Begin an indented unfilled display.
- .\"
- .\" .DE
- .\" End of indented unfilled display.
- .\"
- '\" # Heading for Tcl/Tk man pages
- .de HS
- .ds ^3 \\0
- .if !"\\$3"" .ds ^3 \\$3
- .if '\\$2'cmds' .TH \\$1 1 \\*(^3 \\$4
- .if '\\$2'lib' .TH \\$1 3 \\*(^3 \\$4
- .if '\\$2'tcl' .TH \\$1 n \\*(^3 Tcl "Tcl Built-In Commands"
- .if '\\$2'tk' .TH \\$1 n \\*(^3 Tk "Tk Commands"
- .if '\\$2'tclc' .TH \\$1 3 \\*(^3 Tcl "Tcl Library Procedures"
- .if '\\$2'tkc' .TH \\$1 3 \\*(^3 Tk "Tk Library Procedures"
- .if '\\$2'tclcmds' .TH \\$1 1 \\*(^3 Tk "Tcl Applications"
- .if '\\$2'tkcmds' .TH \\$1 1 \\*(^3 Tk "Tk Applications"
- .if t .wh -1.3i ^B
- .nr ^l \\n(.l
- .ad b
- ..
- '\" # Start an argument description
- .de AP
- .ie !"\\$4"" .TP \\$4
- .el \{\
- . ie !"\\$2"" .TP \\n()Cu
- . el .TP 15
- .\}
- .ie !"\\$3"" \{\
- .ta \\n()Au \\n()Bu
- \&\\$1 \\fI\\$2\\fP (\\$3)
- .\".b
- .\}
- .el \{\
- .br
- .ie !"\\$2"" \{\
- \&\\$1 \\fI\\$2\\fP
- .\}
- .el \{\
- \&\\fI\\$1\\fP
- .\}
- .\}
- ..
- '\" # define tabbing values for .AP
- .de AS
- .nr )A 10n
- .if !"\\$1"" .nr )A \\w'\\$1'u+3n
- .nr )B \\n()Au+15n
- .\"
- .if !"\\$2"" .nr )B \\w'\\$2'u+\\n()Au+3n
- .nr )C \\n()Bu+\\w'(in/out)'u+2n
- ..
- '\" # BS - start boxed text
- '\" # ^y = starting y location
- '\" # ^b = 1
- .de BS
- .br
- .mk ^y
- .nr ^b 1u
- .if n .nf
- .if n .ti 0
- .if n \l'\\n(.lu\(ul'
- .if n .fi
- ..
- '\" # BE - end boxed text (draw box now)
- .de BE
- .nf
- .ti 0
- .mk ^t
- .ie n \l'\\n(^lu\(ul'
- .el \{\
- .\" Draw four-sided box normally, but don't draw top of
- .\" box if the box started on an earlier page.
- .ie !\\n(^b-1 \{\
- \h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul'
- .\}
- .el \}\
- \h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul'
- .\}
- .\}
- .fi
- .br
- .nr ^b 0
- ..
- '\" # VS - start vertical sidebar
- '\" # ^Y = starting y location
- '\" # ^v = 1 (for troff; for nroff this doesn't matter)
- .de VS
- .mk ^Y
- .ie n 'mc \s12\(br\s0
- .el .nr ^v 1u
- ..
- '\" # VE - end of vertical sidebar
- .de VE
- .ie n 'mc
- .el \{\
- .ev 2
- .nf
- .ti 0
- .mk ^t
- \h'|\\n(^lu+3n'\L'|\\n(^Yu-1v\(bv'\v'\\n(^tu+1v-\\n(^Yu'\h'-|\\n(^lu+3n'
- .sp -1
- .fi
- .ev
- .\}
- .nr ^v 0
- ..
- '\" # Special macro to handle page bottom: finish off current
- '\" # box/sidebar if in box/sidebar mode, then invoked standard
- '\" # page bottom macro.
- .de ^B
- .ev 2
- 'ti 0
- 'nf
- .mk ^t
- .if \\n(^b \{\
- .\" Draw three-sided box if this is the box's first page,
- .\" draw two sides but no top otherwise.
- .ie !\\n(^b-1 \h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c
- .el \h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c
- .\}
- .if \\n(^v \{\
- .nr ^x \\n(^tu+1v-\\n(^Yu
- \kx\h'-\\nxu'\h'|\\n(^lu+3n'\ky\L'-\\n(^xu'\v'\\n(^xu'\h'|0u'\c
- .\}
- .bp
- 'fi
- .ev
- .if \\n(^b \{\
- .mk ^y
- .nr ^b 2
- .\}
- .if \\n(^v \{\
- .mk ^Y
- .\}
- ..
- '\" # DS - begin display
- .de DS
- .RS
- .nf
- .sp
- ..
- '\" # DE - end display
- .de DE
- .fi
- .RE
- .sp .5
- ..
- .HS open tcl 7.0
- .BS
- '\" Note: do not modify the .SH NAME line immediately below!
- .SH NAME
- open \- Open a file
- .SH SYNOPSIS
- .VS
- \fBopen \fIfileName\fR ?\fIaccess\fR? ?\fIpermissions\fR?
- .VE
- .BE
-
- .SH DESCRIPTION
- .PP
- This command opens a file and returns an identifier
- that may be used in future invocations
- of commands like \fBread\fR, \fBputs\fR, and \fBclose\fR.
- \fIFileName\fR gives the name of the file to open; if it starts with
- a tilde then tilde substitution is performed as described for
- \fBTcl_TildeSubst\fR.
- If the first character of \fIfileName\fR is ``|'' then the
- remaining characters of \fIfileName\fR are treated as a command
- pipeline to invoke, in the same style as for \fBexec\fR.
- In this case, the identifier returned by \fBopen\fR may be used
- to write to the command's input pipe or read from its output pipe.
- .PP
- The \fIaccess\fR argument indicates the way in which the file
- (or command pipeline) is to be accessed.
- .VS
- It may take two forms, either a string in the form that would be
- passed to the \fBfopen\fR library procedure or a list of POSIX
- access flags.
- It defaults to ``\fBr\fR''.
- In the first form \fIaccess\fR may have any of the following values:
- .VE
- .TP 15
- \fBr\fR
- Open the file for reading only; the file must already exist.
- .TP 15
- \fBr+\fR
- Open the file for both reading and writing; the file must
- already exist.
- .TP 15
- \fBw\fR
- Open the file for writing only. Truncate it if it exists. If it doesn't
- exist, create a new file.
- .TP 15
- \fBw+\fR
- Open the file for reading and writing. Truncate it if it exists.
- If it doesn't exist, create a new file.
- .TP 15
- \fBa\fR
- Open the file for writing only. The file must already exist, and the file
- is positioned so that new data is appended to the file.
- .TP 15
- \fBa+\fR
- Open the file for reading and writing. If the file doesn't exist,
- create a new empty file.
- Set the initial access position to the end of the file.
- .PP
- In the second form, \fIaccess\fR consists of a list of any of the
- .VS
- following flags, all of which have the standard POSIX meanings.
- One of the flags must be either \fBRDONLY\fR, \fBWRONLY\fR or \fBRDWR\fR.
- .TP 15
- \fBRDONLY\fR
- Open the file for reading only.
- .TP 15
- \fBWRONLY\fR
- Open the file for writing only.
- .TP 15
- \fBRDWR\fR
- Open the file for both reading and writing.
- .TP 15
- \fBAPPEND\fR
- Set the file pointer to the end of the file prior to each write.
- .TP 15
- \fBCREAT\fR
- Create the file if it doesn't already exist (without this flag it
- is an error for the file not to exist).
- .TP 15
- \fBEXCL\fR
- If \fBCREAT\fR is specified also, an error is returned if the
- file already exists.
- .TP 15
- \fBNOCTTY\fR
- If the file is a terminal device, this flag prevents the file from
- becoming the controlling terminal of the process.
- .TP 15
- \fBNONBLOCK\fR
- Prevents the process from blocking while opening the file.
- For details refer to your system documentation on the \fBopen\fR system
- call's \fBO_NONBLOCK\fR flag.
- .TP 15
- \fBTRUNC\fR
- If the file exists it is truncated to zero length.
- .PP
- If a new file is created as part of opening it, \fIpermissions\fR
- (an integer) is used to set the permissions for the new file in
- conjunction with the process's file mode creation mask.
- \fIPermissions\fR defaults to 0666.
- .VE
- .PP
- If a file is opened for both reading and writing then \fBseek\fR
- must be invoked between a read and a write, or vice versa (this
- restriction does not apply to command pipelines opened with \fBopen\fR).
- When \fIfileName\fR specifies a command pipeline and a write-only access
- is used, then standard output from the pipeline is directed to the
- current standard output unless overridden by the command.
- When \fIfileName\fR specifies a command pipeline and a read-only access
- is used, then standard input from the pipeline is taken from the
- current standard input unless overridden by the command.
-
- .SH KEYWORDS
- access mode, append, controlling terminal, create, file,
- non-blocking, open, permissions, pipeline, process
-